As a day-to-day C# developer, I'm curious about a few things: - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? (Apologies that I didn't read the source code.)
Hello There, I'm the owner of this repo. So nice that has ended here somehow. Gonna answer the upper quests... - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? The GC dosn't cause noticeable pausing on my setup. Even tho it could allocate less. - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? In fact it was done without unsafe code…
ProjectPSX – A C# coded emulator of the original Playstation
41–50 of 62 posts
Re: ProjectPSX – A C# coded emulator of the original Playstation
#42As a day-to-day C# developer, I'm curious about a few things: - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? (Apologies that I didn't read the source code.)
I haven't read the code, but you usually don't let the garbage collector get a chance to do anything with projects where it matters.
The .Net garbage collector is a highly optimized generational garbage collector. Practices like pre-allocating and pooling are discouraged, because most of the time they are premature optimization.
In general, the best way to think about it is to pretend that the garbage collector is a built-in library for pooling and reusing objects.
If, early in your project's lifecycle, you suspect that you'll need to implement your own object pool, just start with stub "Get/Recycle" methods that call new / no-op. You can always swap in a pool later.
Re: ProjectPSX – A C# coded emulator of the original Playstation
#43As a day-to-day C# developer, I'm curious about a few things: - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? (Apologies that I didn't read the source code.)
Hello There, I'm the owner of this repo. So nice that has ended here somehow. Gonna answer the upper quests... - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? The GC dosn't cause noticeable pausing on my setup. Even tho it could allocate less. - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? In fact it was done without unsafe code…
Re: ProjectPSX – A C# coded emulator of the original Playstation
#44Super nice and simple to read - e.g. cpu.cs has the thing that does the actual "MUL" and "MOV" etc op codes. Nice :-)
Thanks :-)
Re: ProjectPSX – A C# coded emulator of the original Playstation
#45Earlier quoted context omitted.
They made a survey but that doesn’t mean they will listen to the feedback.
Windows Forms, WPF, C++/CLI, EF 6, .NET Native, WinUI kind of prove that they do, even if it takes a while to actually pay attention. Even in regards to WCF, I am not sure if they won't be forced to provide some gRPC migration path, when some Fortune 500 start to complain rather loudly.
Not sure it’s such a huge deal, .NET core already has the most complex parts of the WCF. It has fast async TCP and named pipe streams. It has .NET binary XML support, DataContractSerializer, XmlDictionaryReader, XmlDictionaryWriter classes, technically IMO better than protocol buffers: no foreign languages, similar level of performance, convertable to/from text XML if you want a human readable format for easier debugging.
When I needed RPC server in a Linux app written in .NET core, I wrote my own WCF-like thing. I’ve made a T4 template which generates requests/response & envelope classes, and channel factories, using compile-time reflection (EnvDTE stuff) of my service contracts. Took me a few hours. These Fortune 500 companies can probably afford doing the same when they need RPC in .NET.
Re: ProjectPSX – A C# coded emulator of the original Playstation
#46Earlier quoted context omitted.
I skimmed the code a little and did a few Github searches on it and it looks like the only unsafe blocks of code are in the core data bus. It's not entirely clear why it was done that way, as the CPU itself is using managed arrays to represent memory. Perhaps it was necessary for speed, as it seems primarily concerned with loading the executables that are to be emulated. Otherwise, everything looks statically allocat…
A rather useful pattern in C# is to load a blob into a byte array, then inside unsafe code, typecast it to a pointer to well-defined struct. There's also managed ways to do that, but they are slower and involve copying memory.
Re: ProjectPSX – A C# coded emulator of the original Playstation
#47> ProjectPSX dosn't use any external dependency and uses rather simplistic C# code. Very impressive. This makes it more interesting to see how the drawing code and the controls were implemented in addition to the possibility of it being cross-platform if it using .NET Core.
It uses System.Windows.Forms and friends. It is a Windows app.
Should be straightforward to port to GTK# or Eto.Forms or something, if one had the inclination.
Re: ProjectPSX – A C# coded emulator of the original Playstation
#48And one in Java: https://github.com/kilograham/jpsx
Re: ProjectPSX – A C# coded emulator of the original Playstation
#49Earlier quoted context omitted.
Windows Forms, WPF, C++/CLI, EF 6, .NET Native, WinUI kind of prove that they do, even if it takes a while to actually pay attention. Even in regards to WCF, I am not sure if they won't be forced to provide some gRPC migration path, when some Fortune 500 start to complain rather loudly.
> when some Fortune 500 start to complain rather loudly Not sure it’s such a huge deal, .NET core already has the most complex parts of the WCF. It has fast async TCP and named pipe streams. It has .NET binary XML support, DataContractSerializer, XmlDictionaryReader, XmlDictionaryWriter classes, technically IMO better than protocol buffers: no foreign languages, similar level of performance, convertable to/from text…
Re: ProjectPSX – A C# coded emulator of the original Playstation
#50As a day-to-day C# developer, I'm curious about a few things: - Do you ever find that the Garbage Collector causes noticeable pausing in the emulator? - Did you do this with 100% managed memory, or do you need to use unsafe code / real pointers? (Apologies that I didn't read the source code.)
Search the repo for "new" and you'll see that everything is allocated at construction time. Everything hangs off the window class so essentially all memory is allocated as the project starts up. You'd probably want to pre-allocate in any language because but this also relieves GC pressure. Another thing you can do in C# is leverage stack allocation using structs.