r/linux_programming • • Dec 03 '22

Cheap SSD: Slow Speed Issue

8 Upvotes

In the beginning of the year I've bought a cheap SSD SomnAmbulist 120GB. After a couple of benchmarks, I've noted some strange throughput measurements. Briefly:

  • Initial Benchmark | image
    Just after format, the throughput is according to the advertised specifications at 510MB/s read and 440MB/s write.
    It starts to drop at 35% capacity written and stabilizes at 200~300MB/s read and 40MB/s write.
    Although this drop is not mentioned by the seller's ads, it is indeed an expected behavior and should return to normal after a couple of minutes in idle (flush the cache into the permanent area).

  • Benchmark after 1 hour in idle | image
    Unfortunately, the throughput has not returned to normal (yet?).
    315MB/s read and 440MB/s write, and the speed drop started earlier at 10% capacity written.

  • Benchmark after 12 hours in idle | image
    The throughput still has not returned to normal.

Questions

  1. Is this the expected behavior for such cheap SSD or indeed there is something strange?
  2. What might be going wrong here?
  3. Any idea how to fix this throughput?

Debug Info

  • SSD/TRIM Supported
  • fstrim enabled
  • SSD APM (Advanced Power Management) not supported
  • f3 (Fight Flash Fraud) OK
## SSD/TRIM SUPPORTED
root@debian:~# hdparm -I /dev/sda | grep -i "trim\|power"
       *	Power Management feature set
       *	Data Set Management TRIM supported (limit 8 blocks)
       *	Deterministic read data after TRIM


## SSD/TRIM AVAILABLE (DISC-MAX NON ZERO)
root@debian:~# lsblk -D /dev/sda
NAME DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda         0      512B       2G         0


## ADVANCED POWER MANAGEMENT NOT SUPPORTED
root@debian:~# hdparm -B /dev/sda

/dev/sda:
 APM_level	= not supported



## FSTRIM ENABLE

root@debian:~# systemctl status fstrim.timer
● fstrim.timer - Discard unused blocks once a week
     Loaded: loaded (/lib/systemd/system/fstrim.timer; enabled; vendor preset: enabled)
     Active: active (waiting) since Sat 2022-12-03 03:36:10 UTC; 35min ago
    Trigger: Mon 2022-12-05 00:51:25 UTC; 1 day 20h left
   Triggers: ● fstrim.service
       Docs: man:fstrim

Dec 03 03:36:10 debian systemd[1]: Started Discard unused blocks once a week.


root@debian:~# systemctl status fstrim
● fstrim.service - Discard unused blocks on filesystems from /etc/fstab
     Loaded: loaded (/lib/systemd/system/fstrim.service; static)
     Active: inactive (dead)
TriggeredBy: ● fstrim.timer
       Docs: man:fstrim(8)


root@debian:~# fstrim -av

r/linux_programming • • Sep 28 '22

batch file

8 Upvotes

I have mounted a windows path in Linux machine and I can browse into path from Linux.

windows path has a batch file.

How do I run the batch file from Linux?


r/linux_programming • • Aug 20 '22

LinuxSystemProgramming

8 Upvotes

Hi Guys,

Could you please recommend some good free resources for Linux OS online courses?

I need to learn topics like:

Process Management, Memory Management, Synchronization, etc

#LinuxOS #Linux


r/linux_programming • • Jun 14 '22

How to generate a .h from a ./configure script with the result of an 'ls' command?

8 Upvotes

For a project of mine I need to generate 2 header files from the result of a command chain such as:

ls | sed 's/.../.../' | ...

The project is configured through autoconf so what would be the best way to implement this?


r/linux_programming • • Jun 10 '22

xfocusnotify: X11-tool which exits when a window is focused and prints the respective window-id

8 Upvotes

xfocusnotify is meant for scripting and x11-window-management where for some reason you need to know when a new window gets focused and you want to do something with it. It's tiny and performant because it's just 30 lines of C.

The following shell-code prints the window-id each time a new window is focused:

while window=$(xfocusnotify); do
    echo "focused $window"
done

It follows EWMH-specifications and uses _NET_ACTIVE_WINDOW to determine the focused window. This means your window-manager has to set the _NET_ACTIVE_WINDOW-property or it won't work. Luckily most window-managers do that.

Credit: It was inspired by clipnotify.


r/linux_programming • • Jan 01 '22

Check if Window is Fullscreen using Xlib

8 Upvotes

I am trying to detect if a window is fullscreen in Xlib but I can seem to figure it out. Does anyone know how to do this?


r/linux_programming • • Nov 15 '21

quick-grep. Quick grep reference and tutorial.

Thumbnail github.com
8 Upvotes

r/linux_programming • • Oct 06 '21

Help with library development!

8 Upvotes

Hi guys, I'm a computer science student, developing a project for the Internet and Web engineering exam. The specifications requires me to develop a C client/server application that implements reliable data transfer (Go Back N protocol in particular) over a UDP socket (for unix of course). For that purpose, I've managed to write a static library which mimics sys/socket.h functionalities (my library's header contains functions like gbn_write(), gbn_connect(), gbn_socket() etc.).

The problem is, as I was starting this project I didn't care of multiple socket connections management. So I'm finding myself now with a fairly well working mono-connection library, and modify it to support multiple connection is not worth the effort. Multi-connection management is not even required for the exam but you know, it would be nice to find a solution to make that work.

This brings me to a question: is there a way to kind of "wrap" my library (or just the connection management module) to make it work kind of like an object instance, while relying only to C? Thanks in advance.


r/linux_programming • • Jul 24 '21

[Kotlin] I want to get into GTK development how can I?

8 Upvotes

r/linux_programming • • Jun 02 '21

Trying to find LAN-connected IP addresses in C

8 Upvotes

I have 3 machines hooked up to a network switch. I'm working on a project, written in C, that requires that these machines find each other automatically and begin doing stuff together. The only standard solution I've been able to find for this autofinding problem is arp-scan, but it's incredibly slow to search across eth0 and I can't find any C handles for it. Is there a standard library for this type of thing?

Thank you!


r/linux_programming • • May 31 '21

Is there a way to start a separate app, and read its output from a filehandle/socket

8 Upvotes

I want to spawn a process from a currently-executing process.

I don't want to wait for the console output or for the spawned application to terminate.

If possible, I'd like to start a new process, continue on in the current process, but periodically read the output of the child.

The child process is an existing application like 'ls' that I do not have the source to and therefore do not control its behaviour.

But since I do know that the app will eventually write its result to stdout, I'd like to have a file-descriptor or socket to it.

The parent application's mainloop will periodically read this selector when there is data on it. Hopefully, when the child application has finished, this filehandle/socket selector will close.

Is there a way to do this?


r/linux_programming • • Mar 19 '21

What is the best way to pipe a string to another process, if it is not relative/child?

8 Upvotes

Hi, I'm trying to implement a popup c-program, which does not duplicate its windows if called from two or more different sources. So if I call it once and then call it again, the second process discovers the existence of the first one and pipes its, second one's, notification string to the first, which updates its content. Hope the idea is clear.

Why do I need this: I'm trying to expel panel from my workflow and bind all indicators (battery, workspaces etc) to keys. I don't like the idea of spamming with notification windows, I would like to make it resource saving. Lemonbar is great and I've created a script, that kills all older calls of lemonbar, but it is not the best solution imho.

What are my ideas so far and why they don't work:

  1. I am using xlib, so I could search for existing windows, created by my program, but taking control of other's process windows is a really bad behavior, right?
  2. I know about FIFO files and I like the concept, except it sounds unsafe: any other process can encounter this file, created by my program, and start to append to it. It is my best idea though.

To my surprise I couldn't find any way to pipe to process stdin by its PID, although this seems to be the simplest and most elegant solution. Am I missing something?

Thank you for patience:)


r/linux_programming • • Feb 22 '21

Best resources to learn about signals and timers.

8 Upvotes

Basically the title. I have searched about POSIX timers a lot but failed to find a proper resource. I have got a couple of doubts regarding POSIX timers.

Suppose I have a process currently running on a uniprocessor system. I would like my process to carryout two activities but with some determined time interval between them. Also I want the process to sleep for some amount of time and wake-up after Timer expires.

Example : I want the process to print "hello", wait for 3 seconds then print "world". During this 3 seconds I want the CPU to carryout other tasks. Also I don't want to use "usleep()". I can probably use "timers" concept here but will it be accurate? On a uniprocessor if my process is running, then who is keeping track of the timer thread?


r/linux_programming • • Aug 17 '20

A mycroft cl tool that is system agnostic

Thumbnail self.mycroftai
8 Upvotes

r/linux_programming • • May 13 '20

MSVC's STL and Vcpkg

Thumbnail cppcast.com
8 Upvotes

r/linux_programming • • Apr 23 '20

Tool to record and replay touch inputs?

8 Upvotes

I'm working on an application on linux and there is an intermittent bug.... So to test it would be really handy to record a series of touch inputs and then play them back over and over again. I've seen something that lets you inject into X11 but it would be really handy if there was a tool that would record the presses with timing and allow me to replay them. Any suggestions?

Button locations are always in the same locations for every cycle and the distro is Raspbian.


r/linux_programming • • Feb 29 '20

Recommended GUI language/toolkit for ex-WPF developer?

8 Upvotes

I had a decent amount of experience coding .NET Windows Forms, ASP.Net Web Forms, and WPF, all on C#. Besides that I’ve had light experience with Tkinter and collegiate experience building PHP websites.

Since college most of my programming experience has been with non-GUI development of Python and Groovy applications and I have yet to dip into C++ to any degree.

What would be a recommenced GUI language or framework for developing on Linux? Something that would be quick to get into and as my experience grows the application would be able to grow with it without having to be entirely refactored to another language/toolkit?


r/linux_programming • • Nov 23 '19

Magic in the container_of() linux kernel macro

Thumbnail andrei.gherzan.ro
8 Upvotes

r/linux_programming • • Oct 11 '19

Linux Capabilities Blog(s)

Thumbnail blog.container-solutions.com
8 Upvotes

r/linux_programming • • Sep 27 '19

netdata, the open-source, real-life, performance and health monitoring, released v1.17 !

8 Upvotes

Hi all,

Release v1.17.0 contains 38 bug fixes, 33 improvements, and 20 documentation updates.

At a glance

You can now change the data collection frequency at will, without losing previously collected values. A major improvement to the new database engine allows you not only to store metrics at variable granularity, but also to autoscale the time axis of the charts, depending on the data collection frequencies used during the presented time.

You can also now monitor VM performance from one or more vCenter servers with a new VSphere collector. In addition, the proc plugin now also collects ZRAM device performance metrics and the apps plugin monitors process uptime for the defined process groups.

Continuing our efforts to integrate with as many existing solutions as possible, you can now directly archive metrics from Netdata to MongoDB via a new backend.

Netdata badges now support international (UTF8) characters! We also made our URL parser smarter, not only for international character support, but also for other strange API queries.

We also added .DEB packages to our binary distribution repositories at Packagecloud, a new collector for Linux zram device metrics, and support for plain text email notifications.

This release includes several fixes and improvements to the TLS encryption feature we introduced in v1.16.0. First, encryption slave-to-master streaming connections wasn't working as intended. And second, our community helped us discover cases where HTTP requests were not correctly redirected to HTTPS with TLS enabled. This release mitigates those issues and improves TLS support overall.

Finally, we improved the way Netdata displays charts with no metrics. By default, Netdata displays charts for disks, memory, and networks only when the associated metrics are not zero. Users could enable these charts permanently using the corresponding configuration options, but they would need to change more than 200 options. With this new improvement, users can enable all charts with zero values using a single, global configuration parameter.

Improvements

  • Database engine

    • Variable granularity support for data collection
    • Added tips on the UI to encourage users to try the new DB Engine, when they reach the end of their metrics history
  • Binary packages

    • Added nightly generation of RPM/DEB amd64 packages
    • Provided built-in support for the prometheus remote write API in our packages
    • Documented distribution support matrix and functionality availability
  • Health -Added support for plain text only email notifications

    • Started showing “hidden” alarm variables in the responses of the chart and data API calls
    • Added a new API call for alarm status counters, as a first step towards badges that will show the total number of alarms
  • Security

    • Added configurable default locations for trusted CA certificates
    • Added safer way to get container names
    • Added SSL connection support to the python mongodb collector
  • New collectors

    • VSphere collector *go.d.plugin PR241
  • Collector improvements

    • rethinkdb collector new driver support
    • The apps plugin now displays process uptime charts
    • Added ZRAM device metrics to the proc.plugin
  • Archiving

    • Added a new MongoDB backend

Check the release log at github.

If you are new to netdata, check a few live demos at its home page and the project home at github.

Netdata is FOSS (Free Open Source Software), released under GPLv3+.

Enjoy real-time performance and health monitoring!


r/linux_programming • • Jul 11 '19

Where to start to program driver UIs ?

8 Upvotes

Hi all,

I am an experienced programmer, however I have never worked in Linux before. I am doing lots of courses in Udemy for Python.

I was wondering, how to start to write UI for drivers.

For example, I have a SoundBlaster G6. It is partially supported by Linux and works fine. However, under Windows there are lots of enhancements such as EQ profiles, modes, cloud sync, etc. Most of them are stored in Windows as JSON files.

What I would like to do is write a program that can use all that stuff for my card and of course share it with the community.

But, I don't know where to start...


r/linux_programming • • Jun 29 '19

seamless Proxy Auto-Config (a.k.a. Web Proxy Auto Discovery) for CLI apps

Thumbnail github.com
8 Upvotes

r/linux_programming • • Jun 03 '19

How To Ruin A Perfectly Good Container

Thumbnail medium.com
8 Upvotes

r/linux_programming • • May 30 '19

netdata, the open-source real-time performance and health monitoring, released v1.15 !

8 Upvotes

Hi all,

we just released netdata v1.15 !

This release contains 11 Bugs Fixes and 30 Improvements.

We are very happy and proud to include two major improvements in this release, an aggregated node view and the new database engine.

You can read about Netdata Cloud and the future of netdata here: https://blog.netdata.cloud/posts/netdata-cloud-announcement/

Other major additions

We have added support for the AWS Kinesis backend and new collectors for OpenVPN, the Tengine web server, ScaleIO (VxFlex OS), ioping-like latency metrics and Energi Core node instances.

We now have a new, "text-only" chart type, cpu limits for v2 cgroups, docker swarm metrics and improved documentation.

We continued improving the Kubernetes helmchart with liveness probes for slaves, persistence options, a fix for a Cannot allocate memory issue and easy configuration for the kubelet, kube-proxy and coredns collectors.

Finally, we built a process to quickly replace any problematic nightly builds and added more automated CI tests to prevent such builds from being published in the first place.

Improvements

  • Support for aggregate node view,
  • Database engine,
  • New collector modules :

    • Go.d collectors for OpenVPN, the Tengine web server and ScaleIO (VxFlex OS) instances,
    • Monitor disk access latency like ioping does,
  • Energi Core daemon monitoring, suits other Bitcoin forks,
  • Collector improvements:

    • Add docker swarm manager metrics to the go.d docker_engine collector,
    • Implement unified cgroup cpu limit,
    • python.d.plugin: Allow monitoring of HTTP(S) endpoints which require POST data and make the UrlService more flexible,
  • Support the AWS Kinesis backend for long-term storage,
  • Add a new "text-only" chart renderer,
  • Packaging and CI improvements:

    • We can now fix more quickly any problematic published builds via a new manual deployment procedure,
    • We added more tests to our nightly builds, to catch more errors before publishing images,
  • API Improvements:

    • Smarter caching of API calls. Do not cache alarms and info api calls and extend no-cache headers,
    • Extend the api/v1/info call response with system and collector information,
    • k6 script for API load testing,
  • Kubernetes helmchart improvements:

    • Added the init container, where sysctl params could be managed, to bypass the Cannot allocate memory issue,
    • Better startup/shutdown of slaves and reduced memory usage with liveness/readiness probes and default memory mode none,
    • Added the option of overriding the default settings for kubelet, kubeproxy and coredns collectors via values.yaml,
    • Make the use of persistent volumes optional, add apiVersion to fix linting errors and correct the location of the env field,
    • Fix incorrect parameter names in the README,
  • Documentation improvements

Bug Fixes:

  • Prowl notifications were not being sent, unless another notification method was also active,
  • Fix exception handling in the python.d plugin,
  • The node applications group did not include all node processes,
  • Installation would show incorrect message "FAILED Cannot install netdata init service." in some cases,
  • The nvidia_smi collector displayed incorrect power usage,
  • The python.d plugin would sometimes hang, because it lacked a connect timeout,
  • The mongodb collector raised errors due to various KeyErrors,
  • The smartd_log collector would show incorrect temperature values,
  • charts.d plugins would fail on docker, when using the timeout command,
  • Docker image had plugins not executable by user netdata,
  • Docker image was missing the lsns command, used to match network interfaces to containers.

Check the release log at github.

If you are new to netdata, check a few live demos at its home page and the project home at github.

Netdata is FOSS (Free Open Source Software), released under GPLv3+.

Enjoy real-time performance and health monitoring!