configuration – Argon2id configuration for multiple threads

We are using argon2-jvm use Argon2id on our Java TCP server.

Because it is argon2id the instance is thread safe, we plan to create only one instance for the lifetime of our application and have each request handler call it when needed (for example for new registrations and user logins).

We have adjusted our single argon2id Therefore, hash and verification passwords take approximately 1 second in a single thread using the approach of This answer:

  1. Use the maximum number of threads we can use.
  2. Use the maximum amount of memory we can use.
  3. Adjust the number of iterations so that it does not exceed our maximum target time (1 second in our case).

However, when the number of threads that access our argon2id instance increases (for example multiple users log in and log in) its runtime also increases.

Our plan now is to reconfigure our argon2id instance in such a way that it still takes about 1 second to decrypt and verify passwords, but instead of doing it in just 1 thread, we will do this at our maximum expected number of concurrent logs and logins at any given time (for example, 500 requests).

Our concern is that if we do, then our hashes might not be secure enough because each request will not receive as much processing as it should (for example, a hash that takes approximately 1 second at maximum capacity might take only 0.25 seconds when it's the only request that is made).

We feel that configure Argon2id for maximum capacity you will underestimate your settings for each individual request. Is this how it's supposed to be done? Or should we continue with our configuration which takes 1 second on individual threads but takes longer on multiple ones?

Use of threads struck in C!

Hi
I need to develop this solution: https://www.urionlinejudge.com.br/judge/pt/problems/view/1253 using Threads in C. I got the following result:

#include 
#include 
#include 
#include 

struct args {
    char text(50);
    int num;
};

void *Thread_Um(void *teste) {
    char a*;
    for(int i = 0; i < 1; i++) {
        char valor1 = ((struct args*) teste)-> text(i);
        int valor2 = ((struct args*) teste)-> num;
        int l = sizeof(valor1);
        for(int j = 0; j < l; j++) {
            a = valor1(j) - valor2;
            if(a < 65)
               a+= 26;
            printf("%c",a);
        }
        printf("n");
    }
    pthread_exit(NULL);
}

int main(int argc, char *argv()) {
    pthread_t thread(2);
    char a;

    struct args *Valores = (struct args *)malloc(sizeof(struct args));
    for(int i = 0; i < 1; i++) {
        scanf("%s", Valores->text(i));
        scanf("%d", &Valores->num);
    }

    pthread_create(&thread(0), NULL, Thread_Um, (void *)Valores);
    pthread_exit(NULL);
}

However, it returns this error:
error: the subscribed value is neither array nor pointer nor vector on line a = value1 (j) – value2;
Would anyone know the reason for this error?
Thanks for your attention!

Under what conditions does gmail group different responses into a single thread? How can I force separate threads?

If I have an ad in kijiji, and I get two responses on the same day, they are considered a single conversation, and I have to separate them.

Sometimes I send out a newsletter by email using mailchimp. ALL responses to it are grouped into a single conversation.

I just did a test from another account, sending the same message, the same subject, twice 1 minute apart. They ended in separate threads. Therefore, an identical subject line in a short period of time is not enough, however kijiji's responses are different messages.

The following are ideas that I don't know how to test.

  • If I use the address + string function, are messages to different strings considered the same thread? For example, if my normal Gmail address is j.random.user@gmail.com and I add (How?) A

    Reply to: j.random.user + 0037

in the headers, will gmail consider them as separate threads from the original?

  • The same idea, but modify the From: header instead.

multi-thread: a simple secure Deque for threads in C ++

I am trying to implement a secure deque for threads in C ++.
ThreadSafeDeque will be used by a FileLogger class.
When the threads call log() function of FileLogger the messages will be push_back()ed to ThreadSafeDeque and come back almost immediately. In a separate thread, the FileLogger pop_front() messages and write them in a file at your own pace.
Am I doing things correctly next?

#pragma once
#include 
#include 
template
class ThreadSafeDeque {
public:
    void pop_front_waiting(T &t) {
        // unique_lock can be unlocked, lock_guard can not
        std::unique_lock lock{ mutex }; // locks
        while(deque.empty()) {
            condition.wait(lock); // unlocks, sleeps and relocks when woken up  
        }
        t = deque.front();
        deque.pop_front();
    } // unlocks as goes out of scope

    void push_back(const T &t) {
        std::unique_lock lock{ mutex }; 
        deque.push_back(t);
        lock.unlock();
        condition.notify_one(); // wakes up pop_front_waiting  
    }
private:
    std::deque               deque;
    std::mutex                  mutex;
    std::condition_variable condition;
};  

Python – How to convert these threads into processes?

This code aims to simulate the problem of the philosopher's bar (http://marcial.larces.uece.br/cursos/programacao-concorrente-e-paralela-2019-2/problema-do-bar-dos-filosofos) This is a generalization of the problem of the philosophers' dinner.
Briefly given a graph, each vertex is a philosopher (process) and each edge is a bottle (shared resource), to drink a philosopher (vertex) you must acquire all the bottles (edges) that affect it, but the bottles are for exclusive use , only a philosopher can have a bottle at any given time.
For this implementation, a philosopher must be an object that runs in a different process
Initially I started with each philosopher being a Thread (because I had already used threads in Python), but I have problems separating them into processes.
In the initial process, a bar_man object is declared that controls an integer vector (which will simulate the bottles), my goal is that the philosophical objects that are executed in other processes call the methods of the bar-man object that are executed in the First process

Class of philosopher (the important thing here are the methods acquire_class () and return_class ()):

class filosofo (threading.Thread):
def __init__ (self, filosofo_id, matrix_grafo):
    #self.meu_id = 'Filosofo ' + str(name)
    self.meu_id = filosofo_id
    self.n_bebidas = 0
    self.tempo_com_sede = 0
    self.tempo_total = 0
    self.estado = 'tranquilo'

    self.minhas_garrafas = self.matrix_grafo_minhas_garrafas(matrix_grafo)

    threading.Thread.__init__ (self) 

def matrix_grafo_minhas_garrafas(self, matrix_grafo):# transforma a matrix_grafo em  uma lista de garrafas (id_garrafa, False)
    arestas = ()
    aux = ()
    for i in range( len(matrix_grafo) ):
        for j in range ( len(matrix_grafo(0)) ):
            if (i <= j) and (matrix_grafo (i)(j) == 1):
                aux.append(i)
                aux.append(j)
                arestas.append(aux)
            aux = ()
    #print(arestas)
    garrafas = ()
    aux = ()
    for k in range( len(arestas) ):
        if (self.meu_id == arestas(k)(0)) or (self.meu_id == arestas(k)(1)):
            aux = (k, False)
            garrafas.append(aux)
    return garrafas

def print_info(self):
    print('n')
    print('Filosofo - {}'.format(self.meu_id))
    print('Garrafas - {}'.format(self.minhas_garrafas))
    print('Vezes bebidas - {}'.format(self.n_bebidas))
    print('Tempo com sede - {}'.format(self.tempo_com_sede))
    print('Tempo total a o final da execução - {}'.format(self.tempo_total))
    print('n')

def adquirir_garrafas (self):
    print ("filosofo - {} esta com sede".format(self.meu_id)) 

    n_garrafas = random.randint( 2, len(self.minhas_garrafas) )
    pedido = ()
    for i in range(n_garrafas):
        pedido.append( self.minhas_garrafas(i) )

    global pedidos_0, pedidos_3, pedidos_9

    if self.meu_id == 0:
        pedidos_0.append(pedido)
    if self.meu_id == 3:
        pedidos_3.append(pedido)
    if self.meu_id == 9:
        pedidos_9.append(pedido)


    print('{}° pedido do filosofo {} - {}'.format(self.n_bebidas, self.meu_id, pedido))
    #LOCK

    global bar_man
    bar_man.dar_garrafas(pedido, self.meu_id)

def beber (self):
    self.estado = 'com_sede'
    aux_time = time.time()

    self.adquirir_garrafas() 

    self.estado = 'bebendo'
    self.tempo_com_sede = self.tempo_com_sede + (time.time() - aux_time)

    self.n_bebidas = self.n_bebidas + 1
    print ("filosofo - {} bebendo pela {}° vez".format(self.meu_id, self.n_bebidas))
    time.sleep (1)
    self.estado = 'tranquilo'
    print ("filosofo - {} terminou de beber pela {}° vez".format(self.meu_id, self.n_bebidas))

    self.devolver_garrafas()

def devolver_garrafas (self):

    global bar_man

    bar_man.receber_garrafas(self.meu_id)

    #UNLOCK

    print ("filosofo - {} terminou devolver as garrafas".format(self.meu_id))

def viver (self):
    for i in range (5):
        self.beber()
        time.sleep (random.randint(0, 2))# de 0 a 2

def run (self):
    tempo_total = time.time()
    if self.meu_id == 0 or self.meu_id == 3 or self.meu_id == 9:# AQUI
        self.viver()
        self.print_info()
        tempo_total = time.time() - tempo_total

Class_bar control

class controle_bar(object):
def __init__ (self, matrix_grafo):
    self.controle = ()# (lista garrafas, id filosofo)
    self.prateleira = ()

    arestas = ()
    aux = ()
    for i in range( len(matrix_grafo) ):
        for j in range ( len(matrix_grafo(0)) ):
            if i <= j and (matrix_grafo (i)(j) == 1):
                aux.append(i)
                aux.append(j)
                arestas.append(aux)
            aux = ()
    aux = ()
    for k in range( len(arestas) ):
        aux = (k, -1)
        self.controle.append(aux)
        self.prateleira.append(aux(0))

def print_info(self):
    print(self.controle)
    print(self.prateleira)  

def dar_garrafas(self, lista, id_filosofo):#AINDA ESTA SEM CONTROLE DE ACESSO   LISTA -> (ID_GARRAFA, TRUE/FALSE)

    for i in range( len(lista) ):

        for k in range( len(self.controle) ):

            if self.controle(k)(0) == lista(i)(0):# se id garrafa controle igual a id garrafa lista

                self.controle(k)(1) = id_filosofo

    for i in range( ( len(lista) ) ):
        self.prateleira.remove( lista(i)(0) )

    return True

def receber_garrafas(self, id_filosofo):#AINDA ESTA SEM CONTROLE DE ACESSO   LISTA -> (ID_GARRAFA, TRUE/FALSE) outra implemenetação

    for i in range( len(self.controle) ):

        if self.controle(i)(1) == id_filosofo:# se id filosofo controle igual a id filosofo

            self.prateleira.append( self.controle(i)(0) )

            self.controle(i)(1) = -1

    return True

Principal function

import threading 
import time 
import random 

class filosofo (threading.Thread):

class controle_bar(object):

#matrix_grafo = ((0,1), (1,0))
#matrix_grafo = ((0, 1, 0, 0, 1), (1, 0, 1, 0, 0), (0, 1, 0, 1, 0), (0, 0, 1, 0, 1), (1, 0, 0, 1, 0))
#matrix_grafo = ((0, 1, 0, 0, 0, 1), (1, 0, 1, 0, 0, 0), (0, 1, 0, 1, 0, 1), (0, 0, 1, 0, 1, 1), (0, 0, 0, 1, 0, 1), (1, 0, 1, 1, 1, 0))
matrix_grafo = ((0, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0), (1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0), (1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), (0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0), (1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0), (0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0), (0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0), (0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0), (0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1), (0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, 1), (0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1), (0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0))

threads = ()
numero_de_filosofos = len(matrix_grafo)
bar_man = controle_bar(matrix_grafo)

for i in range (numero_de_filosofos):
    novo_filosofo = filosofo (i, matrix_grafo)
    threads.append (novo_filosofo)
    novo_filosofo.start ()

for t in threads:
    t.join ()

Note
1- In the method of execution there is a problem that causes only philosophers 0, 3, 9 to run (they do not share bottles with each other), I did it because I have not yet implemented the solution.

2- matrix_grafo is an array with instances of the problem, it has 3 examples, only one should be left as an executable line and the others as comments

3- In the methods acquire acquire_ bottles (), return_ bottles () call the bar_man methods that are give_ bottles () and receive_ bottles ()

4 - All the order variables are records of the bottles that each philosopher asked for each time he drank, the number of bottles each time is random between 2 and n being the number of vertices that affect the philosopher

5- each philosopher drinks 5 times

In summary, I want to pass an "object pointer" bar_man that runs in the first process to the processes that philosophers execute

.net – Performance: is there any reason to use processes in threads?

This is a general question, but I work in the .NET world, so I would like to know if there are specific peculiarities about the .NET Framework / Core platforms that should concern me here.

I think it is safe to say that, as a general rule, dividing long-running jobs into threads could be a little faster than dividing jobs into long-running processes. However, the amount of performance difference would be negligible. I have not made any reference point on this, but this answer seems to indicate that there is a consensus on this, at least in regards to .NET.

However, I still hear the argument "It was divided into separate processes for performance reasons" often. I am baffled by this and I wonder if this argument ever carries weight. Remember that this discussion has nothing to do with maintainability. The question I ask: Are multiple jobs executed in a single process, each necessarily faster than several jobs in a single thread each within a process?

Intuitively, I would have to guess that the answer is no. For example, 10 long-running jobs that run in 10 threads should run with approximately the same performance as 10 long-running jobs in 10 different processes. However, I see that people make the design decision to divide the services into smaller parts for the sole purpose of performance.

What I suspect is happening is that the poor quality code has created scenarios in which starvation occurs. I think what is happening is that parallelism is being used in excess and CPU availability is not respected, so the benefits of multiple cores are eroding because jobs are fighting for the power of the CPU. Even so, this doesn't really explain why dividing a job into separate processes would improve performance.

So, How can I demonstrate that a] performance does not improve by dividing the work into separate processes, or b] the improvements made by dividing the code into separate processes are due only to the bad design of the code in the first place?

Sale: 1000 threads with unlimited daily solutions for only $ 250 per month! The | Proxies123.com

Hi,

I would like to offer you another round of special offer. Now we have the MEGA # 2 special package. This package is very different from those currently offered on our site.

This package is a great budget savings. You can enjoy 1000 threads for only $ 250 USD per month and it comes with UNLIMITED DAILY RESOLUTIONS too…

features:

1. 1000 threads
2. UNLIMITED DAILY RESOLUTIONS
3. 20 Elite Proxies

To subscribe just go to https://captchas.io/?p=19

Thank you and God bless you!

java: invocation of multiple threads in the rest web service

I have a scenario in our web application.

The GUI invokes a rest web service and the additional web service calls a procedure. However, the procedure returns data correctly for most scenarios. In some scenarios, it takes more than 5 minutes and the session timeout expires. Now the client suggested that, in this case, if any procedure takes more than 2 minutes, you should return to the GUI with a message "XLS WILL BE SENT BY EMAIL" and when the procedure returns the data (Let Say after 10 minutes) , you must mail the xls to the requested mail ID.

I have an approach as of now.

To implement a verification while the procedure call is initiated and if it crosses 2 minutes, another Rest Service will be invoked and the existing Service message will be returned. Now from the second web service you will send by mail the xls.

But this approach will take longer 2 minutes + 10 minutes (Response of the procedure).

Please guide me the best approach for this implementation.

Keep in mind that the GUI team, the web service team and the database team are different and work in different organizations.

I need this urgently.

Thanks in advance ..

Multiple Threading: Is my server's design safe with respect to multiple threads and concurrent database reads / writes?

I am creating a chat server using sockets and a MySQL database, and after it works, I want to expand it to make it a more complex game server.

I want to know if my design is missing something.

Specifically, I am concerned about accessing the database from different threads, or if I may be creating too many threads and if there is likely to be a bottleneck somewhere.

I have 3 functions:

principal function start a second thread for the ServerHandler function that repeats and accepts new customer connections. That ServerHandler function then opens a new thread for each client connection for a ClientHandler function.

The code / pseudocode (so far incomplete while I am still considering the architecture) is below. I am writing it in Scala.

My main questions are about the ClientHandler function and if I am doing something in the wrong order. Will I be at risk of separate client threads performing database writes and reads in an unexpected order that cause irreproducible problems?

I wonder if I need a separate thread with a list of commands to execute, so I can be sure that 1 client writes and then reads, then another client writes and then reads, etc. Do I need to maintain a read / write list of the database? Or does the database server handle it in some way?

Mainly, I would like to be aware of my lack of understanding of database readings / writes in different threads, and if there is something obvious that I am doing wrong here. Does the design of the program structure look good?

With regard to threads, will I have to test the server with many client connections (1k, 10k, 100k?) And then set some client connection limit to what I think is safe?

// ** ClientHandler **
// This is run in a new thread for each client that connects to the ServerHandler
// This does:
// 1. Set up input and output streams to communicate with 1 client
// 2. Set up connection to database (MySQL server running on the same machine), including:
//    a. Establish connection
//    b. Read some data from the database (latest version #, # of clients connected, etc)
// 3. Send welcome message to client (latest version #, # of clients connected, etc)
// 4. Set "startTime" variable to current system time in milliseconds to detect client timeout
// 5. Loop and do this (nothing is blocking, so irrelevant steps will be skipped):
//    1. Handle client message (if there is a new one), including:
//       a. Parse client message, including:
//          i. If we have not verified the client yet, we only accept one command: "connect"
//          ii. On "connect", we verify the ID and update the database (most recent log in time)
//       b. Database reads/writes/updates as necessary, depending on the command
//       c. Send a response message back to the client with the results
//    Even if there is no client message received, we do this:
//    2. Check for server-side updates that should be notified to the client, including:
//       a. Database reads
//       b. Timestamp comparisons, checking when we last notified the client of the server state
//    3. Notify client of any server-side state changes (if necessary)
// 6. If the client times out (~5000ms), update the database that the client has disconnected
// 7. Close database connection
// 8. Close socket
ClientHandler(socket){
    // Set up input and output streams to communicate with 1 client
    val inputstream = new BufferedReader(new InputStreamReader(socket.getInputStream()))
    val outputstream = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()))

    // Set up connection to database (MySQL server running on the same machine)
    val db = Database.forConfig("mydb")
    // Read some data from the database (latest version #, # of clients connected, etc)
    ...

    // Send welcome message to client (latest version #, # of clients connected, etc)
    outputstream.write(...).newLine().flush()

    // Set "startTime" variable to current system time in milliseconds to detect client timeout
    var startTime = System.currentTimeMillis()

    //
    ...
}

// ** ServerHandler **
// This runs once in its own thread (because it contains a blocking call)
// This creates a new thread to run ClientHandler for each client that connects
ServerHandler(server_socket){
    while(true){
        val socket = server_socket.accept() // this is a blocking call
        val client_handler = new ClientHandler(socket)
        val thread = new Thread(client_handler)
        thread.start() // when a client connects, start a new thread to handle that client
    }
}

// ** main **
// This does 3 things:
// 1. Start a new thread for ServerHandler which sits and waits for clients to connect
// 2. Loop and accept commands from admin via console
// 3. Process server-side logic in real-time
main{
    // Start a new thread for ServerHandler
    val server_socket = new ServerSocket(port 10000)
    val server_handler = new ServerHandler(server_socket)
    val thread = new Thread(server_handler)
    thread.start() // start a thread for the server handler

    // Loop and accept commands from admin via console
    while(true){
        input match{
            case "stats" =>
                // print stats (# of clients logged in etc)
            case "quit" =>
                // close server_socket etc and stop program
            case _ =>
                // unrecognized command
        }
    }
}

1000 threads with unlimited daily solutions for only $ 250 per month!

I would like to offer you another round of special offer. We now have the special MEGA # 2 package. This package is very different from those currently offered on our site.
This package is a great budget savings. You can enjoy 1000 threads for only $ 250 USD per month and it comes with UNLIMITED DAILY RESOLUTIONS too…
features:
1. 1000 threads
2. UNLIMITED DAILY RESOLUTIONS
3. 20 Elite Proxies
To subscribe just go to https://captchas.io/?p=19
Thank you and God bless you!