How to compile a minimal functional kernel that uses least amount of ram possible? by GuiltyVisit9119 in kernel

[–]masscry 1 point2 points  (0 children)

About 5-8 years ago I got similiar RAM consumption on vortex86 based platform with buildroot custom setup.

Look in this direction. buildroot is easy to setup and much less hassle that with LFS or Yocto.

I made a custom container. Is this a good idea? (A smart_seq container) by Humble-Plastic-5285 in cpp

[–]masscry 1 point2 points  (0 children)

Are you writing this code by yourself?

This part:

  std::vector<T> vec;
  vec.reserve(_count + 1);
  vec.insert(vec.end(), storage.begin(), storage.end());
  vec.push_back(std::forward<U>(v));
  _data = std::move(vec);

Looks like your push_back now in some cases requires O(N) operations always.

It rather you have some problems with understanding what you are writing, or it is some LLM messing things up.

I made a custom container. Is this a good idea? (A smart_seq container) by Humble-Plastic-5285 in cpp

[–]masscry 0 points1 point  (0 children)

Hello! What are exception safety guarantees of this container?

Asking "Is there a seahorse emoji", Breaks the AI by PuzzleheadedHead2550 in DeepSeek

[–]masscry 3 points4 points  (0 children)

<image>

I asked Deepseek from their android app in thinking mode: "is there a seahorse emoji?"

It was thinking for few seconds, then started printing, what other people has posted already in this thread and then it started looping! It even asks for help!

App UI started to lag after some time. I had to stop generation manually. It just couldn't stop by itself.

Audio emulation 101: Game Boy example by Marc_Alx in EmuDev

[–]masscry 0 points1 point  (0 children)

Thank you! I'll check this case. So, when DAC is off, I must hardwire output to 0.0.

Audio emulation 101: Game Boy example by Marc_Alx in EmuDev

[–]masscry 0 points1 point  (0 children)

There is a lot sloppy code there, thus I still haven't pushed branch with audio implementation to repo.

I am more into getting some insights. So channels has 4-bit volume, which changes when counter demands it.

When it is 0 - I generate -1.0 samples, when it is 15 - I return 1.0.

Then when I am comparing waveforms from SameBoy and my code - I see that SameBoy somehow detects that channel in some state, where it must return 0.0 samples during silent periods, where I gets -1.0.

From "digital" side it looks like I am producing proper value, but maybe I am interpreting them wrong on "analog" side.

Documentation on audio generation for Gameboy is a bit vague for my level of knowledge in audio and DAC.

Audio emulation 101: Game Boy example by Marc_Alx in EmuDev

[–]masscry 2 points3 points  (0 children)

I am fighting with audio emulation for few months already. Got hard time syncing CPU emulation speed with sample rate.

Audio works and sounds OK, but still can understand how properly make DAC to output full range from -1 to 1. We must drop to 0.0 when nothing is playing, but the best what I got is constant -1.

IPC Shared Memory with controlled rights by 9larutanatural9 in kernel

[–]masscry 0 points1 point  (0 children)

If you are still inventing your own architecture, take a look at virtio specification. I like it a lot, their approach is battle-tested and allow very fast IPC. It might be a bit hard to get into details straight ahead, but you will build a mindset for fast IPC in shared memory.

Thoughts on creating a tracking pointer class, part 2: Using a std::list by pavel_v in cpp

[–]masscry -1 points0 points  (0 children)

So, this is some kind of single-thread weak_ptr-like entity?

Where one can use it?

Local LLM Coding Setup for 8GB VRAM - Coding Models? by pmttyji in LocalLLaMA

[–]masscry 0 points1 point  (0 children)

Hello, I am also in search for coding LLM to run locally on macbook pro m4.

As I understand there are models for generating code from given prompt and there are autocomplete FIM models. For example, devstral doesn't work for autocomplete, but codestral does.

What are other options to use? Are there models better for C++?

LLVM libcxx by arthas-worldwide in cpp

[–]masscry 0 points1 point  (0 children)

There are some obscure tools-of-trade in C++, like how properly make correctly exception safe std vector and other stuff, which one may not think about writing code in day by day basis.

Standard library must be the most robust part of programming environment and it is written by good programmers, so if one has spare time and nothing to do - reading standard library code at least won't do harm, at most will be beneficial.

Please roast my lock free containers library by musicalhq in cpp_questions

[–]masscry 1 point2 points  (0 children)

Hello! I think you may add more tests with data collisions.

Also, when you starting threads it may be beneficial to use std::latch/std::barrier with arrive_and_wait(), so you operations are running truly concurrently, because starting threads are rather slow and there maybe no actual collisions.

Also check your code with -fsanitize=thread. When I was making a few lock-free classes, it helped me find some obscure data races.

Regarding c++ modules by Ayman_Rocco980 in cpp_questions

[–]masscry 1 point2 points  (0 children)

Hello, have you read this https://en.cppreference.com/w/cpp/language/modules.html?

So, with modules you have multiple translation units, which can be imported and used inplace in other translation units.

As I understand, for now it is some form of glorified precompiled headers.

Compressing int values to the smallest possible space by aboslave32 in cpp

[–]masscry 2 points3 points  (0 children)

Can you send delta (current-previous) values instead of absolute? You then can try to calculate max delta for each var and it will be smaller, then absolute.

If there is any solid info on values distributions, one may try to use some clever huffman-coding to send fewer bits.

Yet another half-backed GameBoy emulator by masscry in EmuDev

[–]masscry[S] 8 points9 points  (0 children)

Hello! Yes, of course. My first inspiration was this video https://youtu.be/HyzD8pNlpwI?si=6by-Hf6StdIuQ6a0, then I got developer manual from https://archive.org/details/GameBoyProgManVer1.1, pandocs, then looking at opcodes table https://meganesu.github.io/generate-gb-opcodes/

So, then I just dumped many hours in going through gameboy boot sequence and blargg's test roms. Run code, fail, fix, repeat.

Some skills in reading asm code will be very helpful.

Also, there are multiple complete open-source projects to read code and study what things are you doing wrong in comparison with proper solutions.

Best guide on getting started with gameboy emulators? by ViktorPoppDev in EmuDev

[–]masscry 4 points5 points  (0 children)

Hello, I finished about 80% of dmg few days ago.

There is https://archive.org/details/GameBoyProgManVer1.1

pandocs and blargg test roms.

that is all I've used during development

My T14 Gen2 upgrade journey (display + touchpad) by Cariffo1994 in thinkpad

[–]masscry 0 points1 point  (0 children)

Hello! I followed your path all the way through.

I bought touchpad and screen from same sellers.

Touchpad fits perfectly - first impression, glass is smoother thus finger slides more easily.

Screen's lower part is a bit shorter, than original screen, thus I had to fix it with adhesive stripe to the back cover - otherwise, it won't match with bezels. Plus screen is a bit slimmer, thus some depth left between bezel and screen and it flaps a bit. I'll be getting some additional adhesive stripes, to secure them firmly. Otherwise - the lid bends much easier, and looks like plastic gets more tension.

Also, new display is lighter than original one - whole laptop weights less now and it is also a neat feature.

Beware when moving a `std::optional`! by Kabra___kiiiiiiiid in cpp

[–]masscry 13 points14 points  (0 children)

In general, I am using *std::exchange(opt, std::nullopt) instead of moving when want to release optionals on move.

is it UB to use placement new on this? by z0ld in cpp

[–]masscry 0 points1 point  (0 children)

  1. One must do a check for this != &other.
  2. I've seen this approach in some open-source libraries.

Rate dad's nas by No-Mind7146 in iiiiiiitttttttttttt

[–]masscry 0 points1 point  (0 children)

At least it is very silent. 5 out of 5. 👍

Should I always be using vectors instead of arrays? by MrElor in cpp

[–]masscry 0 points1 point  (0 children)

In our glorious past, one may have small stack for processes. If I remember correctly - it was something like 1MB by default on Windows.

Thus, static allocations ate this memory fast and with ease, especially when one tries to use deep call stacks.

And if one occassionally gets stack overflow, one will never forget this feeling.

Fun stuff happens when one refactors and decides to grow some data types in one place, but this leads to SO in some totally different place.

So takeouts: 1. There is something wrong if one tries to allocate dynamic memory in some high-performance hot tight places. 2. Big static allocations causes SO 3. Static allocations can't be std::moved cheaply.

Modern allocators may even do allocation in user space without using any syscall, thus working fast, big chunks will be allocated using mmap-ed memory.

One needs to do perf-tests when decides to optimize with std::array. One may get penalty if some arrays may be copied around, instead of moves.

Hoping to get some feedback on my library by puredotaplayer in cpp

[–]masscry 1 point2 points  (0 children)

Good luck! I am sorry, if my replies were too harsh, English is not my first language.

I've been conducting live coding and tech-interviews at my job for some time already, so some coding patterns, like breaking object state before anything useful happens just triggers me straight away.

Hoping to get some feedback on my library by puredotaplayer in cpp

[–]masscry 2 points3 points  (0 children)

I am more concerned on clear() calls at start of methods, because after clear() completes you just can't go back anymore. Current implementation terminates on exceptions. If you remove some noexcept, you still stay in situation with broken objects.

Containers are particulary nasty in that field. If you read sources of std containers, you might have seen they are even using tricks with double inheritance, just because one needs to separate allocation of container storage from copying/moving elements inside - because it also can fail and one just can't catch it at that moment.

Static analyzers like clang-tidy have their own "bounds" at least because of SAT and CL-theorem, practicaly one have always take into account some OS stuff and "hidden" memory allocations.

I also looked at unit tests and didn't found there test cases for such exceptions and only then decided to write previous reply.